package com.lucas_main.uvicultimate;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class listActivity extends ListActivity{

	static final String[] Food = new String[] {
		"Ice Cream", "Bacon", "Sandwich", "Mayonaise", "Cheese"};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		try{
			Log.d("", "Got inside onCreate");
			
			setListAdapter( new ArrayAdapter<String>(this, R.layout.single_thread_item, Food));
			
			ListView list = getListView();	
			OnItemClickListener listener = new OnItemClickListener(){

				@Override
				public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
						long arg3) {
					// TODO Auto-generated method stub
					Toast.makeText(getApplicationContext(), ((TextView) arg1).getText(), Toast.LENGTH_SHORT).show();
				}
				
			};
			
			
			list.setTextFilterEnabled(true);
			list.setOnItemClickListener(listener);
		}
		catch (Exception e){
			Log.e("Problem in On Create", e.toString());
		}
	}
	
}
